﻿@using Localization.Resources.AbpUi
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.MultiTenancy
@using Volo.Abp.UI.Navigation
@using Volo.Abp.Users
@inject ICurrentUser CurrentUser
@inject ICurrentTenant CurrentTenant
@inject IHtmlLocalizer<AbpUiResource> L
@model ApplicationMenu

<div class="dropdown">
    <a class="btn d-flex align-items-center" href="#" id="Toolbar_UserMenu" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        <i class="fas fa-user me-1"></i>
        <small class="d-none d-sm-none d-md-none d-lg-block" title="@(CurrentUser.TenantId.HasValue?CurrentTenant.Name+"\\":"") @CurrentUser.UserName">
            @CurrentUser.UserName
        </small>
    </a>

    @if (Model.Items.Any())
    {
        <div class="dropdown-menu dropdown-menu-lg-end" aria-labelledby="Toolbar_UserMenu">
            @foreach (var menuItem in Model.Items)
            {
                var elementId = string.IsNullOrEmpty(menuItem.ElementId) ? string.Empty : $"id=\"{menuItem.ElementId}\"";
                var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass;
                var disabled = menuItem.IsDisabled ? "disabled" : string.Empty;
                var url = string.IsNullOrEmpty(menuItem.Url) ? "#" : Url.Content(menuItem.Url);
                <a class="dropdown-item  @cssClass @disabled" href="@url" target="@menuItem.Target" @Html.Raw(elementId)>
                    @if (menuItem.Icon != null)
                    {
                        <i class="@menuItem.Icon"></i>
                    }
                    @menuItem.DisplayName
                </a>                    
            }
        </div>
    }
</div>
